/*
 * This code is property of Threadsy. Use, duplication and disclosure
 * in any form without permission of copyright holder is prohibited.
 *
 */

package com.nen.session;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author amitm
 */
public class GlobalFilter implements Filter {

    public void init(FilterConfig fc) throws ServletException {
        //
    }

    public void doFilter(ServletRequest request,
            ServletResponse response,
            FilterChain chain)
            throws IOException, ServletException {
        System.out.println("Inside GlobalFilter, url = "+((HttpServletRequest)request).getRequestURL()+", query="+((HttpServletRequest)request).getQueryString());
        System.out.println("GlobalFilter redirectUrl="+((HttpServletRequest)request).getParameter("redirectURL"));
        System.out.println("GlobalFilter method="+((HttpServletRequest)request).getParameter("method"));

        NenHttpServletResponseWrapper responseWrapper = new NenHttpServletResponseWrapper((HttpServletResponse)response);
        chain.doFilter(request, responseWrapper);
        System.out.println("GlobalFilter exit");
    }

    public void destroy() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

}
